<template>
    <div class="container">
        <!-- 选项 -->
        <div class="position-relative">
            <ul class="nav nav-tabs">
                <li class="nav-item">
                    <a class="nav-link" :href="'/profile/'+userId">个人信息</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link " :href="'/mypost/'+userId">我的帖子</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" :href="'/myreply/'+userId">我的回复</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link active"  :href="'/mycource/'+userId">我的课程</a>
                </li>
                
            </ul>
            <a :href="'/profile/'+userId" class="text-muted position-absolute rt-0">返回个人主页&gt;</a>
        </div>
        <!-- 我的帖子 -->
        <div class="mt-4">
            <!-- <h6><b class="square"></b> 发布的帖子({{ifshow ? content.total : 0}})</h6> -->
            <ul class="list-unstyled mt-4 pl-3 pr-3">
                <li class="border-bottom pb-3 mt-4" v-for="(item,i) in content" :key="i">
                    <div class="font-size-16 text-info">
                        <!-- <a :href="'/discussdetail/'+item.discussPost.id" class="text-info">
                          {{item.discussPost.title}}
                        </a> -->
                        {{item.name}}
                    </div>
                    <div class="mt-1 font-size-14">
                      {{item.summary}}
                    </div>
                    <div  class="text-right text-muted" style="margin-bottom:10px">
                          <router-link v-bind:to="'/detail?id=' + item.id" class="btn btn-outline-secondary">课程详情</router-link>
                          <router-link  v-bind:to="'/newindex?id='+item.id" style="margin-left:10px" class="btn btn-outline-secondary">问答</router-link>
                    </div>
                    <div class="text-right font-size-12 text-muted">
                      发布于 <b>{{item.createdAt |datatime}}</b> 
                    </div>
                </li>																	
            </ul>
            <!-- 分页 -->
           				
        </div>				
    </div>
</template>

<script>
import Pagination from "@/components/pagination";
export default {
    name:'mycource',
    data(){
        return{
            content: [
                // {
                //     "id": "00000001",
                //     "name": "测试课程01",
                //     "summary": "这是一门测试课程",
                //     "time": 514,
                //     "price": 19.9,
                //     "image": "https://imooc-course-wu.oss-cn-shenzhen.aliyuncs.com/course/mIwK79iC.jpg?versionId=CAEQLBiBgMCsz977_xciIGFjM2ZhZTY1ZDhmMzQ5ZDU5NmI5YmViZGIxNjM3NDMw",
                //     "level": "1",
                //     "charge": "C",
                //     "status": "P",
                //     "enroll": 100,
                //     "sort": 0,
                //     "createdAt": "2022-02-22T15:49:01.000+0000",
                //     "updatedAt": "2022-02-28T15:57:51.296+0000",
                //     "teacherId": "m0KwhFfi"
                // },
                // {
                //     "id": "9JYBinZU",
                //     "name": "Vue",
                //     "summary": "概述",
                //     "time": null,
                //     "price": null,
                //     "image": "http://imooc-course-wu.oss-cn-shenzhen.aliyuncs.com/course/Tmf8Jh6G.png",
                //     "level": "1",
                //     "charge": "F",
                //     "status": "P",
                //     "enroll": null,
                //     "sort": 2,
                //     "createdAt": "2022-04-10T19:59:52.385+0000",
                //     "updatedAt": "2022-04-10T19:59:52.385+0000",
                //     "teacherId": "m0KwhFfi"
                // }
            ],
            ifshow:false,
            userId:"", //用户id
        }
    },
    components: {Pagination},
    created(){
      this.userId = this.$route.params.userId;
    //   this.setIfshow();
    },
    watch:{
  
    },
    mounted(){
        this.getlist(1);
    },
    methods:{
        //获取数据
        getlist(page){
            // let _this = this;
            this.$ajax.post(process.env.VUE_APP_SERVER + '/business/web/member-course/get-user-enroll/'+this.userId, {

            }).then((response)=>{
                // console.log("查询帖子详情结果：", response);
                this.content = response.data.content;
                // this.$refs.pagination.render(page, response.data.content.total);

            })
        },
        //判断对象是有值
        setIfshow(){
            if(this.content != null){
                this.ifshow = true;
            }else{
                this.ifshow = false;
            }
        },
    }
}
</script>

<style lang="scss" scoped>
    @import '@/assets/style/css/global.scss';
</style>